package com.partner.share.work.mq.consumer;

import com.partner.share.work.mq.construction.ActiveMQTopicConst;
import com.partner.share.work.websocket.WebSocketUtil;
import com.partner.share.work.websocket.server.WebsocketService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * @author pengyangyan
 * @version 1.0.0
 * @date 2019年09月29日 09:52:00
 */
//@Component
//@Order(1)
public class ActiveMQTopicSubscriber {

    @Autowired
    WebsocketService websocketService;

     private final static Logger logger = LoggerFactory.getLogger(ActiveMQTopicSubscriber.class);

    @JmsListener(destination = ActiveMQTopicConst.TOPIC_NAME_WEBSOCKET_SYSTEM_NOTICE, containerFactory = ActiveMQTopicConst.BEAN_NAME_JMSLISTENERCONTAINERFACTORY)
    public void subscribeTopicWebsocketSystemNoticeMsg(String message) {
        logger.info("消费了一条主题[{}]消息{}。", ActiveMQTopicConst.TOPIC_NAME_WEBSOCKET_SYSTEM_NOTICE, message);
        websocketService.broadcast(message);
    }
}